package com.xc.disk.web.rest;

import com.xc.disk.bean.DownloadBean;
import com.xc.disk.bean.HashBean;
import com.xc.disk.bean.NoticeBean;
import com.xc.disk.dto.DownloadDto;
import com.xc.disk.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>项目名称: Stars</p>
 * <p>描述: 接收通知</p>
 * <P>创建人:小程 </p>
 * <P>创建人邮箱: 779943476@qq.com</p>
 * <p>创建时间: 2019/11/21</p>
 *
 * @version v1.0
 */
@RestController
public class NoticeRest {

    @Autowired
    private NoticeService noticeService;

    /**
     * 启动通知
     *
     * @param noticeBean 参数
     */
    @PostMapping(value = "/notice")
    public void notice(@RequestBody NoticeBean noticeBean) {
        noticeService.notice(noticeBean);
    }


    /**
     * 上传成功通知
     *
     * @param hashBean 参数
     * @return 文件id
     */
    @PostMapping(value = "/notice/success")
    public String noticeSuccess(@RequestBody HashBean hashBean) {
        return noticeService.noticeSuccess(hashBean);
    }


    /**
     * 下载验证hashCode是否正确
     *
     * @param downloadBean hash信息
     * @return 文件名称
     */
    @PostMapping(value = "/notice/download")
    public DownloadDto noticeDownload(@RequestBody DownloadBean downloadBean) {
        return noticeService.noticeDownload(downloadBean);
    }
}
